<template>
  <div>
      <header><router-link  tag="span" to="/my" class="yo-ico">&#xf07d;</router-link></header>
    <van-address-list
  v-model="chosenAddressId"
  :list="list"
  @add="onAdd"
  @edit="onEdit"
  
/>
  </div>
</template>

<script>
import Vue from 'vue';
import {Toast,AddressList } from 'vant'
Vue.use(AddressList).use(Toast)
export default {
  data() {
    return {
      chosenAddressId: '1',
      list: [
        {
          id: '1',
          name: '张三',
          tel: '13000000000',
          address: '浙江省杭州市西湖区文三路 138 号东方通信大厦 7 楼 501 室'
        },
        {
          id: '2',
          name: '李四',
          tel: '1310000000',
          address: '浙江省杭州市拱墅区莫干山路 50 号'
        }
      ],
    }
  },

  methods: {
    onAdd() {
     this.$router.push('/add')
    },

    onEdit(item, index) {
      Toast('编辑地址:' + index);
    }
  },
  mounted () {
      if(this.$route.query.data){
           this.$route.query.data.id=this.list.length+1
           this.list.unshift(this.$route.query.data)
      }
   
      
  }
}
</script>

<style lang="stylus" scoped>
header 
  height 0.96rem
  background red
  font-size 0.5rem
  color white
  line-height 0.8rem 
  .spn 
    color white
   
</style>